/**
 * main.c
 * program utama, menjalankan inisialisasi awal dan process loop
 * Sun, 6 Dec 2009
 * By Karol Danutama 13508040
 * */

#include <stdio.h>
#include "../system/system.h"


//KAMUS GLOBAL
TNodeList NodeList; //Array of nodes/sites
TAdjMatrix m; //Adjacency matrix
TAdjList a; //Adjacency list

int main() {
	
	//INISIALISASI AWAL DO NOT CHANGE ORDER!
	AssignConstantValue();
	modus = 1;
	currentNode = 0;
	currentFile = CharToString("");
	CreateEmptyNodeList(&NodeList);
	CreateEmptyAdjMatrix(m);
	CreateEmptyAdjList(&a);
	//END INISIALISASI AWAL
	
	
	//PROCESS LOOP
	//Membaca perintah pertama
	command = ReadCommand(NULL , modus , &NodeList , currentNode);
	while (!(IsStringEqual(LowerCase(command.argument[1]) , ExitCommand) && modus == 1)) {
		//Menjalankan perintah yang baru dibaca
		ExecuteCommand(&modus , &NodeList , m , &a , &currentNode , &currentFile);
		//Mensinkronisasi konsistensi nilai - nilai dalam tabel
		Synchronize(&NodeList , &m , NodeList.node[currentNode]);
		//Membaca perintah berikutnya
		command = ReadCommand(NULL , modus , &NodeList , currentNode);
	}
	//END PROCESS LOOP
	
	return 0;
}
